package javatest;
import java.util.Scanner;
public class Triangle1 {
    public static class Triangle extends GeometricObject {
        private double side1;
        private double side2;
        private double side3;
        public Triangle()
        {
            this.side1 = 1;
            this.side2 = 1;
            this.side3 = 1;
        }
        public Triangle(double side1,
                        double side2, double side3)
        {
            this.side1 = side1;
            this.side2 = side2;
            this.side3 = side3;
        }
        public double getSide1() {
            return side1;
        }
        public double getSide2() {
            return side2;
        }
        public double getSide3() {
            return side3;
        }
        public double getPerimeter() {
            return side1 + side2 + side3;
        }
        public double getArea() {
            double s = getPerimeter() / 2;
            return Math.sqrt(s * (s - side1)
                    * (s - side2) * (s - side3));
        }
        @Override
        public String toString() {
            return "Triangle :side1=" + side1 + ", " +
                    "side2=" + side2 + ", side3=" + side3 ;
        }

    }
    public  static class GeometricObject {
        private String color = "white";
        private boolean filled ;
        private java.util.Date dateCreated;
        public GeometricObject()
        {
           dateCreated = new java.util.Date();
        }
        public GeometricObject(String color,boolean filled)
        {
            dateCreated = new java.util.Date();
            this.color = color;
            this.filled = filled;
        }

        public String getColor() {
            return color;
        }
        public void setColor(String color) {
            this.color = color;
        }
        public boolean isFilled() {
            return filled;
        }
        public void setFilled(boolean filled) {
            this.filled = filled;
        }
        public java.util.Date getDateCreated()
        {
            return dateCreated;
        }

        @Override
        public String toString() {
            return "created on "+ dateCreated + "\ncolor:" + color + " and filled: " + filled;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter three sides of the triangle:");
        double side1 = scanner.nextDouble();
        double side2 = scanner.nextDouble();
        double side3 = scanner.nextDouble();
        if (isValidTriangle(side1, side2, side3)) {

            Triangle triangle = new Triangle(side1, side2, side3);
            System.out.println("Enter color:");
            triangle.setColor(scanner.next());
            System.out.println("Is the triangle filled? (true/false):");
            triangle.setFilled(scanner.nextBoolean());
            System.out.println("Perimeter: " + triangle.getPerimeter());
            System.out.println("Area: " + triangle.getArea());
            System.out.println(triangle);
            System.out.println("The triangle's color is "+ triangle.getColor()+
                    " the triangle is filled? " + triangle.isFilled());
        } else {
            System.out.println("Invalid input! The sum of any" +
                    " two sides must be greater than the third.");
        }
    }
    public static boolean isValidTriangle(double side1, double side2, double side3) {
        return side1 + side2 > side3 && side1 + side3 > side2 && side2 + side3 > side1;
    }
}
